import React, { useState } from 'react'
import {Button, Input,Space,}from 'antd'
import {redirect, useNavigate} from 'react-router-dom'
export default function login() {
  const [a,seta]=useState('')
  const navigate = useNavigate()
  const b=(e:any)=>{
seta(e.target.value)

  }
  const admin = ()=>{
    if(a==="xiaolu"){

  
    navigate("/edit")  }else{
      window.alert("请输入口令")
      redirect("/")
      location.reload()
    }
  }
  
  const pri=()=>{
    navigate('/home')
  }
  return (
    <div>
      <h1>pi业主用户登录</h1><br></br>
     口令: <Input  value={a} onChange={b} style={{width:220}} /><br></br>
   
         <Space>
         <Button type="primary" onClick={pri}>游客登陆方式</Button>
   <Button type="primary" onClick={admin}>管理员登陆方式</Button>
         </Space>
   
  </div>

  )
}
